<?php

namespace App\Modules\Admin\Http\Controllers\Apparatus;

use App\Modules\Admin\Http\Controllers\BaseController;
use App\Modules\Admin\Http\Requests\Apparatus\ApparatusRequest;
use App\Modules\Admin\Services\Water\Apparatus\ApparatusLogService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ApparatusLogController extends BaseController
{
    public function __construct(ApparatusLogService $apparatusService)
    {
        $this->service = $apparatusService;
    }

    public function create(ApparatusRequest $request): JsonResponse
    {
        return $this->createService($request);
    }

    /**
     * 物业 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function getPropertyFee (Request $request): JsonResponse
    {
        $result = $this->service->getPropertyFee ($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 水费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function getWaterRate (Request $request): JsonResponse
    {
        $result = $this->service->getWaterRate ($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 水费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function getElectricity (Request $request): JsonResponse
    {
        $result = $this->service->getElectricity ($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
}
